package com.study.happystudy.mapper;

import com.study.happystudy.po.ExamPaper;
import com.study.happystudy.po.Question;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ExamPaperMapper {

    // 添加试卷
    void insertExamPaper(@Param("startTime") String startTime,
                         @Param("endTime") String endTime,
                         @Param("examType") String examType,
                         @Param("grade") int grade,
                         @Param("name") String name,
                         @Param("subjectId") int subjectId,
                         @Param("totalScore") int totalScore,
                         @Param("teacherId") int teacherId
    );

    // 删除试卷
    void deleteExamPaperById(int examPaperId);

    // 根据id返回试卷
    ExamPaper getExamPaperById(int examPaperId);

    // 修改试卷
    void updateExamPaper(
            @Param("examPaperId") int examPaperId,
            @Param("name") String name,
            @Param("examType") String examType,
            @Param("grade") int grade,
            @Param("subjectId") int subjectId,
            @Param("totalScore") int totalScore,
            @Param("startTime") String startTime,
            @Param("endTime") String endTime
    );

    // 查询试卷(根据年级，科目id)
    List<ExamPaper> findExamPapersByGradeAndSubject(@Param("grade") int grade, @Param("subjectId") int subjectId);

    // 给学生发布试卷
    void assignExamPaperToStudent(@Param("studentId") int studentId, @Param("examPaperId") int examPaperId);

    // 展示题目(根据题目顺序排序)
    List<Question> listQuestionsByExamPaperId(int examPaperId);
    void insertQuestion(
            @Param("examPaperId") int examPaperId,
            @Param("questionId") int questionId,
            @Param("questionOrder") int questionOrder
    );

    List<ExamPaper> getExamPapersBySubjectId(@Param("subjectId") int subjectId);
}
